﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using TraceabilityApp_Api.Application.Command.DeepProcessing_深加工_;
using TraceabilityApp_Api.DTO;
using TraceabilityApp_Domain;
using TraceabilityApp_ErrorCode;

namespace TraceabilityApp_Api.Controllers
{
    /// <summary>
    /// 溯源深加工控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DeepProcessingController : ControllerBase
    {
        private readonly IMediator mediator;

        public DeepProcessingController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 添加深加工信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> AddDeepProcessing(AddDeepProcessingCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 深加工信息修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> UpdateDeepProcessing(UpdateDeepProcessingCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 深加工信息列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<DeepProcessingDTO>> GetDeepProcessing([FromQuery]GetDeepProcessingCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 深加工企业信息添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> AddEnterprise(AddEnterpriseCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 深加工企业信息修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> UpdateEnterprise(UpdateEnterpriseCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 深加工企业信息显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<EnterpriseDTO>> GetEnterprise([FromQuery]GetEnterpriseCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 深加工供应商信息添加            
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> AddSupplier(AddSupplierCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 深加工供应商信息删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> DelSupplier(DelSupplierCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 深加工供应商信息显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<SupplierModel>>> GetSupplier([FromQuery]GetSupplierCommand request)
        {
            return mediator.Send(request);
        }
    }
}
